package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.item.client.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.support.BindingAwareModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李旭
 * @date 2022/1/8 9:35
 * @Description:
 * 商品详情页面 页面渲染
 */
@Controller
public class ItemController {


    @Autowired
    private ItemFeignClient itemFeignClient;

    //进入商品详情页面 http://item.gmall.com  /10042914533406.html
    @GetMapping("/{skuId}.html")
    public String itemHtml(@PathVariable Long skuId, Map map){
        Map result = itemFeignClient.getItem(skuId);
        map.putAll(result);//K  V
        return "item/index";
    }

}
